import java.awt.*;

public class FreshThread extends Thread {
    public static int fresh = 20;
    public static final int FRESH = 20;

    GamePanel p;

    public FreshThread(GamePanel p) {
        this.p = p;
    }

    public static void addSpeed() {
        fresh -= 2;
        if (fresh < 1) fresh = 1;
    }

    public void run() {
        while(!p.isFinish()) {
            if(!p.isPaused) this.p.repaint();
            try {
                Thread.sleep(fresh);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        Container c=p;
        while (!(c instanceof MainWindow frame)){
            c = c.getParent();
        }
        new ScoreDialog(frame);
        frame.restart(p.theme);
    }
}
